#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>

int main(int argc, char *argv[]) {
  int in, out;
  char *less_args[] = {"less", NULL};

  // open input and output files

  in = open("blah.txt", O_RDONLY);
  //out = open("out", O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR);

  // replace standard input with input file

  dup2(in, 0);

  // replace standard output with output file

  //dup2(out, 1);

  // close unused file descriptors

  close(in);
  //close(out);

  // execute grep

  execvp("less", less_args);
  //return EXIT_SUCCESS;
}   
